home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
12956
/
12956.xpi
/
chrome
/
fabtab.jar
/
content
/
fabtab
/
fabtab.js
next >
Wrap
Text File
|
2009-11-27
|
30KB
|
637 lines
window.addEventListener("load", function(event) {FabTabOverlay.Initialize();}, false);
window.addEventListener("unload", function(event) {FabTabOverlay.DeInitialize();}, false);
var FabTabWebProgressListener =
{
QueryInterface: function(aIID)
{
if (aIID.equals(Components.interfaces.nsIWebProgressListener) || aIID.equals(Components.interfaces.nsISupportsWeakReference) || aIID.equals(Components.interfaces.nsISupports)) return this;
throw Components.results.NS_NOINTERFACE;
},
onStateChange: function(aWebProgress, aRequest, aFlag, aStatus)
{
if(aFlag & Components.interfaces.nsIWebProgressListener.STATE_STOP && aFlag & Components.interfaces.nsIWebProgressListener.STATE_IS_NETWORK)
{
if (document.defaultView.FabTabOverlay)
{
var aTabs = getBrowser().mTabs;
var oTab;
var iIndex, iLen = aTabs.length;
for (iIndex = 0; iIndex < iLen; iIndex ++)
{
if (aTabs[iIndex].linkedBrowser && aTabs[iIndex].linkedBrowser.contentDocument.location == aWebProgress.DOMWindow.document.location)
{
oTab = aTabs[iIndex];
setTimeout(function() {document.defaultView.FabTabOverlay.UpdateTabs(oTab);}, 100);
}
}
}
}
return 0;
},
onLocationChange: function(aProgress, aRequest, aURI) {return 0;},
onProgressChange: function() {return 0;},
onStatusChange: function() {return 0;},
onSecurityChange: function() {return 0;},
onLinkIconAvailable: function() {return 0;}
}
var FabTabOverlay =
{
bInitialized:false,
Initialize: function()
{
this.oPreferences = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
this.oPreferences = this.oPreferences.getBranch("extensions.fabtab.");
var oAppInfo = Components.classes["@mozilla.org/xre/app-info;1"].getService(Components.interfaces.nsIXULRuntime);
var oContainer = getBrowser().tabContainer;
if (oContainer)
{
this.bIsRunningUnderLinux = (oAppInfo.OS == "Linux");
var oTabMixPlusItem;
try
{
var oEM = Components.classes["@mozilla.org/extensions/manager;1"].getService(Components.interfaces.nsIExtensionManager);
if (oEM.getItemForID) {oTabMixPlusItem = oEM.getItemForID("{dc572301-7619-498c-a57d-39143191b318}");}
else {oTabMixPlusItem = oEM.getItemList("{dc572301-7619-498c-a57d-39143191b318}", null, {})[0];}
} catch (e) {oTabMixPlusItem = null;}
if (oTabMixPlusItem && this.bIsRunningUnderLinux)
{
/*Tab Mix Plus under Linux fix...*/
oContainer.setAttribute("fabtab_for_linux_tmp", "true");
}
else
{
oContainer.setAttribute("fabtab_for_linux", this.bIsRunningUnderLinux);
}
oContainer.setAttribute("fabtab_colorbottombox", this.oPreferences.getBoolPref("colorbottombox"));
}
if (this.bInitialized) return true;
this.oPrefObserver =
{
observe: function(subject, topic, prefName)
{
if (topic == "nsPref:changed" && prefName.indexOf("extensions.fabtab.") >= 0)
{
setTimeout(function() {FabTabOverlay.RefreshAll(false);}, 100);
}
}
};
this.bInitialized = true;
this.oStrings = document.getElementById("fabtab-string-bundle");
this.aPixelCache = null;
this.aPixelCache = [];
var oPrefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranchInternal);
oPrefService.addObserver("extensions.fabtab.fuzzycolormatch", this.oPrefObserver, false);
oPrefService.addObserver("extensions.fabtab.x", this.oPrefObserver, false);
oPrefService.addObserver("extensions.fabtab.y", this.oPrefObserver, false);
oPrefService.addObserver("extensions.fabtab.width", this.oPrefObserver, false);
oPrefService.addObserver("extensions.fabtab.height", this.oPrefObserver, false);
oPrefService.addObserver("extensions.fabtab.preventwhite", this.oPrefObserver, false);
oPrefService.addObserver("extensions.fabtab.preventblack", this.oPrefObserver, false);
oPrefService.addObserver("extensions.fabtab.activeonly", this.oPrefObserver, false);
oPrefService.addObserver("extensions.fabtab.opacity", this.oPrefObserver, false);
oPrefService.addObserver("extensions.fabtab.activetabopacity", this.oPrefObserver, false);
oPrefService.addObserver("extensions.fabtab.disabletabbgimage", this.oPrefObserver, false);
oPrefService.addObserver("extensions.fabtab.whitetextthreshold", this.oPrefObserver, false);
oPrefService.addObserver("extensions.fabtab.hostnamecache", this.oPrefObserver, false);
var oContainer = getBrowser().tabContainer;
oContainer.addEventListener("TabOpen", function(event) {event.originalTarget.linkedBrowser.addProgressListener(FabTabWebProgressListener, Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);}, false);
oContainer.addEventListener("TabClose", function(event) {event.originalTarget.linkedBrowser.removeProgressListener(FabTabWebProgressListener, Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);}, false);
oContainer.addEventListener("TabSelect", function(event) {FabTabOverlay.UpdateTabs();}, false);
var aTabs = getBrowser().mTabs;
var iIndex, iLen = aTabs.length;
for (iIndex = 0; iIndex < iLen; iIndex ++)
{
aTabs[iIndex].linkedBrowser.addProgressListener(FabTabWebProgressListener, Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
}
this.UpdateTabs();
this.InitializeTabContextMenu();
},
InitializeTabContextMenu: function()
{
if (!this.oPreferences.getBoolPref("hidecmitems"))
{
if (!document.getElementById('fabtab-context-clear'))
{
var oMenuPopup = document.getAnonymousElementByAttribute(gBrowser, "anonid", "tabContextMenu")
var oElement;
oElement = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', "menuseparator");
oMenuPopup.appendChild(oElement);
oElement = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', "menuitem");
oElement.setAttribute("id", "fabtab-context-clear");
oElement.setAttribute("label", this.GetString("fabtab.context.clear"));
oElement.setAttribute("oncommand", "FabTabOverlay.RefreshAll(true);");
oMenuPopup.appendChild(oElement);
oElement = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', "menuitem");
oElement.setAttribute("id", "fabtab-context-clearall");
oElement.setAttribute("label", this.GetString("fabtab.context.clearall"));
oElement.setAttribute("oncommand", "FabTabOverlay.RefreshAll(false);");
oMenuPopup.appendChild(oElement);
}
}
},
DeInitialize: function()
{
var oContainer = getBrowser().tabContainer;
oContainer.removeEventListener("TabOpen", function(event) {event.originalTarget.linkedBrowser.addProgressListener(FabTabWebProgressListener, Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);}, false);
oContainer.removeEventListener("TabClose", function(event) {event.originalTarget.linkedBrowser.removeProgressListener(FabTabWebProgressListener, Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);}, false);
var oPrefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranchInternal);
oPrefService.removeObserver("extensions.fabtab.fuzzycolormatch", this.oPrefObserver, false);
oPrefService.removeObserver("extensions.fabtab.x", this.oPrefObserver, false);
oPrefService.removeObserver("extensions.fabtab.y", this.oPrefObserver, false);
oPrefService.removeObserver("extensions.fabtab.width", this.oPrefObserver, false);
oPrefService.removeObserver("extensions.fabtab.height", this.oPrefObserver, false);
oPrefService.removeObserver("extensions.fabtab.preventwhite", this.oPrefObserver, false);
oPrefService.removeObserver("extensions.fabtab.preventblack", this.oPrefObserver, false);
oPrefService.removeObserver("extensions.fabtab.activeonly", this.oPrefObserver, false);
oPrefService.removeObserver("extensions.fabtab.opacity", this.oPrefObserver, false);
oPrefService.removeObserver("extensions.fabtab.activetabopacity", this.oPrefObserver, false);
oPrefService.removeObserver("extensions.fabtab.disabletabbgimage", this.oPrefObserver, false);
oPrefService.removeObserver("extensions.fabtab.whitetextthreshold", this.oPrefObserver, false);
oPrefService.removeObserver("extensions.fabtab.hostnamecache", this.oPrefObserver, false);
this.bInitialized = false;
},
RefreshAll: function(bResetCurrentOnly)
{
if (bResetCurrentOnly)
{
this.aPixelCache[this.GetURL(getBrowser().selectedTab.linkedBrowser.contentDocument.URL)] = "";
}
else
{
this.aPixelCache = null;
this.aPixelCache = [];
}
this.UpdateTabs();
},
UpdateTabs: function(oTab)
{
var bActiveOnly = this.oPreferences.getBoolPref("activeonly");
var oTabs;
if (oTab && !bActiveOnly) oTabs = new Array(oTab);
else oTabs = getBrowser().mTabs;
var oWindow;
var oCanvas = document.getElementById("fabtab-canvas");
var oContext = oCanvas.getContext("2d");
var oImageData;
var oPixelArray;
var oTabPreview;
var aPixels;
var aRGBValues = new Array();
var aRGBValue;
var sDataURL, sPixel, sContrastTextColor;
var iPIndex, iPLen, iPixel, iWidth, iHeight;
var iIndex, iFMCount, iLen = oTabs.length;
var iFuzzyColorMatch = this.oPreferences.getIntPref("fuzzycolormatch");
var iPreventWhite = this.oPreferences.getIntPref("preventwhite");
var iPreventBlack = this.oPreferences.getIntPref("preventblack");
var iOpacity = this.oPreferences.getIntPref("opacity") / 100;
var iATOpacity = this.oPreferences.getIntPref("activetabopacity") / 100;
var iNewOpacity = 100;
var iX = this.oPreferences.getIntPref("x");
var iY = this.oPreferences.getIntPref("y");
var iWidth = this.oPreferences.getIntPref("width");
var iHeight = this.oPreferences.getIntPref("height");
var iCWidth = (iWidth / 2);
var iCHeight = (iHeight / 2);
var bRemoveBGImage = this.oPreferences.getBoolPref("disabletabbgimage");
var oContainer = getBrowser().tabContainer;
if (oContainer)
{
oContainer.setAttribute("fabtab_nobgimage", bRemoveBGImage);
}
for (iIndex = 0; iIndex < iLen; iIndex ++)
{
aPixels = null;
aPixels = [];
aRGBValues = null;
aRGBValues = new Array();
if (oTabs[iIndex].localName != "tab") continue;
oWindow = oTabs[iIndex].linkedBrowser.contentWindow;
if (oWindow)
{
try
{
sPixel = "";
try {sPixel = this.aPixelCache[this.GetURL(oTabs[iIndex].linkedBrowser.contentDocument.URL)];}
catch (e) {}
if (this.GetURL(oTabs[iIndex].linkedBrowser.contentDocument.URL) == "about:blank") sPixel = "rgb(255,255,255)";
if (!sPixel || sPixel == "")
{
if (iWidth > (oWindow.innerWidth - 25)) iWidth = oWindow.innerWidth - 25;
if (iHeight > (oWindow.innerHeight - 25)) iHeight = oWindow.innerHeight - 25;
iCWidth = parseInt(iWidth / 2);
iCHeight = parseInt(iHeight / 2);
oCanvas.style.width = iCWidth + "px";
oCanvas.style.height = iCHeight + "px";
oCanvas.width = iCWidth;
oCanvas.height = iCHeight;
oContext.clearRect(0, 0, iCWidth, iCHeight);
oContext.save();
oContext.scale(iCWidth/iWidth, iCHeight/iHeight);
this.HideFrames(oWindow, true);
oContext.drawWindow(oWindow, iX, iY, iWidth, iHeight, "rgb(0,0,0)");
this.HideFrames(oWindow, false);
oContext.restore();
oImageData = oContext.getImageData(0,0,iCWidth,iCHeight);
/*
var oFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
if (!this.iRefreshIndex) this.iRefreshIndex = 0;
oFile.initWithPath("c:\\" + getBrowser().getBrowserIndexForDocument(oTabs[iIndex].linkedBrowser.contentDocument) + "_" + this.iRefreshIndex + ".png");
var io = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
var source = io.newURI(oCanvas.toDataURL("image/png", ""), "UTF8", null);
var target = io.newFileURI(oFile);
var persist = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"].createInstance(Components.interfaces.nsIWebBrowserPersist);
persist.persistFlags = Components.interfaces.nsIWebBrowserPersist.PERSIST_FLAGS_REPLACE_EXISTING_FILES;
persist.persistFlags |= Components.interfaces.nsIWebBrowserPersist.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION;
persist.saveURI(source, null, null, null, null, oFile);
*/
oPixelArray = oImageData.data;
iPLen = oPixelArray.length;
for (iPIndex = 0; iPIndex < iPLen - 3; iPIndex += 4)
{
sPixel = "rgb(" + oPixelArray[iPIndex] + "," + oPixelArray[iPIndex + 1] + "," + oPixelArray[iPIndex + 2] + ")";
if (this.AllowColor(oPixelArray[iPIndex], oPixelArray[iPIndex + 1], oPixelArray[iPIndex + 2], iPreventWhite, iPreventBlack))
{
try
{
iPixel = aPixels[sPixel];
if (!iPixel) iPixel = 0;
if (isNaN(iPixel)) iPixel = 0;
aPixels[sPixel] = iPixel + 1;
}
catch (e)
{
aPixels[sPixel] = 1;
}
}
}
aPixels = this.SortRGBArray(aPixels);
if (this.GetRGBValue(aPixels, 0))
{
for (iPIndex = 0; iPIndex < 32; iPIndex ++)
{
try
{
sPixel = this.GetRGBValue(aPixels, iPIndex);
if (sPixel)
{
aRGBValue = this.RGBValueToRGBArray(sPixel);
aRGBValues[aRGBValues.length] = new Array(aRGBValue, aPixels[sPixel]);
}
}
catch (e) {break;}
}
aPixels = null;
aPixels = [];
iPLen = aRGBValues.length;
for (iPIndex = 0; iPIndex < iPLen; iPIndex ++)
{
iFMCount = this.GetFuzzyMatchColorCount(aRGBValues, aRGBValues[iPIndex], iFuzzyColorMatch);
aPixels[this.RGBArrayToRGBValue(aRGBValues[iPIndex][0])] = (iFMCount * aRGBValues[iPIndex][1]);
aRGBValues[iPIndex][2] = iFMCount;
}
aPixels = this.SortRGBArray(aPixels);
sPixel = this.GetRGBValue(aPixels, 0);
this.aPixelCache[this.GetURL(oTabs[iIndex].linkedBrowser.contentDocument.URL)] = sPixel;
}
}
if (!bActiveOnly || oTabs[iIndex].linkedPanel == getBrowser().selectedTab.linkedPanel)
{
iNewOpacity = iOpacity;
if (oTabs[iIndex].linkedPanel == getBrowser().selectedTab.linkedPanel)
{
iNewOpacity = iATOpacity;
var oBottomBox = document.getElementById("fabtabs-bottom");
if (oBottomBox)
{
oBottomBox.setAttribute("style", "background-color: " + sPixel + " !important;");
}
}
sContrastTextColor = this.GetContrastTextColor(sPixel)
/*Color the tab*/
oTabs[iIndex].style.setProperty("background-color", sPixel, "important");
oTabs[iIndex].style.setProperty("color", sContrastTextColor, "important");
oTabs[iIndex].style.setProperty("opacity", iNewOpacity, "important");
/*Force color the text node*/
var oTabText = document.getAnonymousElementByAttribute(oTabs[iIndex], "class", "tab-text");
if (oTabText) oTabText.style.setProperty("color", sContrastTextColor, "important");
/*Color any anonymous child nodes.*/
if (bRemoveBGImage) this.ColorAnonymousChildNodes(oTabs[iIndex], sPixel);
/*Color the Linux XBL bound tab box*/
if (oTabs[iIndex].mFabTabBox)
{
oTabs[iIndex].mFabTabBox.setAttribute("style", "background-color: " + sPixel + " !important;");
}
/*See if we can color Tab Sidebar previews as well...*/
try
{
oTabPreview = document.getElementsByAttribute("browser", oTabs[iIndex].getAttribute("linkedpanel"))[0];
if (!oTabPreview) oTabPreview = document.getElementById("sidebar").contentDocument.getElementsByAttribute("browser", oTabs[iIndex].getAttribute("linkedpanel"))[0];
if (oTabPreview)
{
oTabPreview.style.setProperty("background-color", sPixel, "important");
oTabPreview.style.setProperty("color", sContrastTextColor, "important");
oTabPreview.style.setProperty("opacity", iNewOpacity, "important");
}
} catch (e) {/*Sidebar closed and/or Tab Preview not installed...*/}
}
else
{
/*Remove the tab styles again*/
oTabs[iIndex].style.backgroundColor = "";
oTabs[iIndex].style.color = "";
oTabs[iIndex].style.opacity = "";
/*Force remove the color on the text node*/
var oTabText = document.getAnonymousElementByAttribute(oTabs[iIndex], "class", "tab-text");
if (oTabText) oTabText.style.color = "";
/*And remove them from any anonymous childs*/
if (bRemoveBGImage) this.ColorAnonymousChildNodes(oTabs[iIndex], null, null);
/*Remove it from the XBL Linux only box*/
if (oTabs[iIndex].mFabTabBox)
{
oTabs[iIndex].mFabTabBox.removeAttribute("style");
}
/*See if we can color Tab Sidebar previews as well...*/
try
{
oTabPreview = document.getElementsByAttribute("browser", oTabs[iIndex].getAttribute("linkedpanel"))[0];
if (!oTabPreview) oTabPreview = document.getElementById("sidebar").contentDocument.getElementsByAttribute("browser", oTabs[iIndex].getAttribute("linkedpanel"))[0];
if (oTabPreview)
{
oTabPreview.style.backgroundColor = "";
oTabPreview.style.color = "";
oTabPreview.style.opacity = "";
}
} catch (e) {/*Sidebar closed and/or Tab Preview not installed...*/}
}
}
catch (e) {this.WriteDebugMessage(e);}
}
}
},
ColorAnonymousChildNodes: function(oParentNode, sBackgroundColor, sTextColor)
{
var oNodes = document.getAnonymousNodes(oParentNode);
if (oNodes)
{
var iIndex, iLen = oNodes.length;
for (iIndex = 0; iIndex < iLen; iIndex ++)
{
if (oNodes[iIndex])
{
if (sBackgroundColor)
{
oNodes[iIndex].style.setProperty("background-color", sBackgroundColor, "important");
oNodes[iIndex].style.setProperty("color", sTextColor, "important");
}
else
{
oNodes[iIndex].style.backgroundColor = "";
oNodes[iIndex].style.color = "";
}
this.ColorAnonymousChildNodes(oNodes[iIndex], sBackgroundColor, sTextColor);
}
}
}
},
HideFrames: function(oWindow, bHide)
{
var aFrames = oWindow.document.getElementsByTagName("IFRAME");
var iIndex, iLen = aFrames.length;
for (iIndex = 0; iIndex < iLen; iIndex ++)
{
try
{
if (bHide)
{
if (aFrames[iIndex].contentDocument.location.host != oWindow.document.location.host)
{
aFrames[iIndex].setAttribute("fabtabdisplay", aFrames[iIndex].style.display);
aFrames[iIndex].style.display = "none";
}
}
else
{
if (aFrames[iIndex].contentDocument.location.host != oWindow.document.location.host)
{
aFrames[iIndex].style.display = aFrames[iIndex].getAttribute("fabtabdisplay");
aFrames[iIndex].removeAttribute("fabtabdisplay");
}
}
} catch (e) {}
}
},
HandleTabSelect: function(oTab)
{
if (oTab) this.UpdateTabs();
},
FindInPixelArray: function(aArray, sFind)
{
var iIndex, iLen = aArray.length;
for (iIndex = 0; iIndex < iLen; iIndex ++) if (aArray[iIndex][0] == sFind) return iIndex;
return -1;
},
GetFuzzyMatchColorCount: function(aRGBValues, aRGBValue, iFuzzyColorMatch)
{
var iROrg = aRGBValue[0][0];
var iGOrg = aRGBValue[0][1];
var iBOrg = aRGBValue[0][2];
var iIndex, iLen;
var iRDiff;
var iGDiff;
var iBDiff;
var iDiff;
var iCount = 0;
iLen = aRGBValues.length;
for (iIndex = 0; iIndex < iLen; iIndex ++)
{
iRDiff = Math.pow((iROrg - aRGBValues[iIndex][0][0]), 2);
iGDiff = Math.pow((iGOrg - aRGBValues[iIndex][0][1]), 2);
iBDiff = Math.pow((iBOrg - aRGBValues[iIndex][0][2]), 2);
iDiff = Math.sqrt(iRDiff + iGDiff + iBDiff);
if (iDiff <= iFuzzyColorMatch)
{
iCount ++;
}
}
return iCount;
},
RGBValueToRGBArray: function(sRGB)
{
sRGB = sRGB.replace("rgb(", "").replace(")", "");
var aRGB = sRGB.split(",");
var iIndex, iLen = aRGB.length;
for (iIndex = 0; iIndex < iLen; iIndex ++) aRGB[iIndex] = parseInt(aRGB[iIndex]);
return aRGB;
},
RGBArrayToRGBValue: function(aRGB)
{
return "rgb(" + aRGB[0] + "," + aRGB[1] + "," + aRGB[2] + ")";
},
SortRGBArray: function(aInput)
{
var aOutput = [];
var aTemp = [];
var sKey;
var iIndex;
for (sKey in aInput) aTemp.push([sKey, aInput[sKey]]);
aTemp.sort(function () {return arguments[0][1] > arguments[1][1]});
for (iIndex = aTemp.length - 1; iIndex >= 0; iIndex --) aOutput[aTemp[iIndex][0]] = aTemp[iIndex][1];
return aOutput;
},
GetRGBValue: function(aRGBArray, iPosition)
{
var sRGBValue;
var iIndex = 0;
for (sRGBValue in aRGBArray)
{
if (iIndex == iPosition) return sRGBValue;
iIndex ++;
}
return "";
},
AllowColor: function(iR, iG, iB, iPreventWhite, iPreventBlack)
{
if (iR > (255 - iPreventWhite) && iG > (255 - iPreventWhite) && iB > (255 - iPreventWhite)) return false;
if (iR < iPreventBlack && iG < iPreventBlack && iB < iPreventBlack) return false;
return true;
},
GetContrastTextColor: function(sRGB)
{
sRGB = sRGB.replace('rgb(', '');
sRGB = sRGB.replace(')', '');
var aRGB = sRGB.split(',');
var iR = parseInt(aRGB[0]);
var iG = parseInt(aRGB[1]);
var iB = parseInt(aRGB[2]);
var iBackY = ((iR * 299) + (iG * 587) + (iB * 114)) / 1000;
var iTextY = ((0 * 299) + (0 * 587) + (0 * 114)) / 1000;
var iBDiff = Math.abs(iBackY - iTextY);
var iCDiff = iR + iG + iB;
var iThreshold = this.oPreferences.getIntPref("whitetextthreshold");
if (iBDiff < iThreshold && iCDiff <= (iThreshold * 2)) return "rgb(255,255,255)"
return "rgb(0,0,0)"
},
GetURL: function(sURL)
{
if (!this.oPreferences.getBoolPref("hostnamecache")) return sURL;
var sHost = sURL;
try
{
var oIOS = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
var oURI = oIOS.newURI(sURL,null,null);
sHost = oURI.host;
}
catch (e) {}
return sHost;
},
GetString: function(sName, sVar1, sVar2, sVar3, sVar4, sVar5, sVar6, sVar7)
{
var sbService = Components.classes["@mozilla.org/intl/stringbundle;1"].getService(Components.interfaces.nsIStringBundleService);
var oStringBundle = sbService.createBundle("chrome://fabtab/locale/fabtab.properties");
var sResult = "";
if(oStringBundle)
{
sResult = oStringBundle.GetStringFromName(sName);
if (sVar1 || (typeof(sVar1) == "number" && sVar1 == 0)) sResult = sResult.replace(/%1/g, sVar1);
if (sVar2 || (typeof(sVar2) == "number" && sVar2 == 0)) sResult = sResult.replace(/%2/g, sVar2);
if (sVar3 || (typeof(sVar3) == "number" && sVar3 == 0)) sResult = sResult.replace(/%3/g, sVar3);
if (sVar4 || (typeof(sVar4) == "number" && sVar4 == 0)) sResult = sResult.replace(/%4/g, sVar4);
if (sVar5 || (typeof(sVar5) == "number" && sVar5 == 0)) sResult = sResult.replace(/%5/g, sVar5);
if (sVar6 || (typeof(sVar6) == "number" && sVar6 == 0)) sResult = sResult.replace(/%6/g, sVar6);
if (sVar7 || (typeof(sVar7) == "number" && sVar7 == 0)) sResult = sResult.replace(/%7/g, sVar7);
}
return sResult;
},
WriteDebugMessage: function(aMsg)
{
var oConsole = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces["nsIConsoleService"]);
oConsole.logStringMessage(aMsg);
}
};